// 获取所有分类
export const reqType = () => request({ url: "/type", method: "get" });

// 根据种类获取分类
export const reqTypeList = (categoryId) =>
  request({ url: `/type/${categoryId}`, method: "get" });

// 添加新的分类或修改分类
export const reqAddOrUpdateType = (data) => {
  if (data._id) {
    return request({ url: "/type", method: "put", data });
  } else {
    return request({ url: "/type", method: "post", data });
  }
};

// 删除类型
export const reqDeleteType = (data) =>
  request({ url: "/type", method: "delete", data });
